package cn.xiaobai.enums;

import java.util.Calendar;

/**
 * 年月日 枚举
 */
public enum TimeTypeEnum {
    YEAR("year", Calendar.YEAR, "年份"),
    MONTH("month", Calendar.MONTH, "月份"),
    DAY("day", Calendar.DAY_OF_MONTH, "日期");


    private String type;
    private int field;
    private String desc;

    TimeTypeEnum(String type, int field, String desc) {
        this.type = type;
        this.field = field;
        this.desc = desc;
    }

    public static Integer getItem(String type) {
        TimeTypeEnum[] values = values();
        for (TimeTypeEnum value : values) {
            if (value.getType().equals(type)) {
                return value.getField();
            }
        }
        return null;
    }

    public String getType() {
        return type;
    }

    public int getField() {
        return field;
    }

    public String getDesc() {
        return desc;
    }
}